const path = require('path');
const webpack = require("webpack");
const loaders = require("./webpack/loaders.js");
const base = require('./webpack.client.base.js');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');

const plugins = [
	new webpack.HotModuleReplacementPlugin(),
	// 在控制台中输出可读的模块名
	new webpack.NamedModulesPlugin(),
	// 避免发出包含错误的模块
	new webpack.NoEmitOnErrorsPlugin(),
	new ProgressBarPlugin({
		summary: false
	})
]

base.devServer = {
	hot: true,
	contentBase: base.entry.path,
	publicPath: base.entry.publicPath
}

Object.keys(base.entry).forEach(function(name) {
	if (name !== 'vendor') {
		base.entry[name] = [
			'react-hot-loader/patch',
			'webpack-hot-middleware/client?reload=true',
			'webpack/hot/only-dev-server'
		].concat(base.entry[name])
	}
})

const config = Object.assign({}, base, {
	// devtool: "eval-source-map",
	devtool: "eval",
	plugins: (base.plugins || []).concat(plugins),
	module: {
		rules: [
			// loaders.jslint,
			// loaders.wasm,
			loaders.html,
			loaders.jsx,
			loaders.styles.css,
			loaders.styles.scss,
			loaders.styles.less,
			loaders.assets,
			loaders.json
		]
	},
	// }
})
module.exports = config;